<?php
/**
 * The MIT License
 *
 * Copyright (c) <year> <copyright holders>
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 *
 * @author Damiano Ciarla
 * @package core
 * @subpackage exception
 */
class BXD_Plugin_Exception extends Exception
{
	/**
	 * Il plugin non è presente
	 */
	const PLUGIN_NOT_FOUND = 1;

	/**
	 * Il file config.php non è presente nel plugin
	 */
	const CONFIG_PHP_NOT_FOUND = 2;

	/**
	 * Una classe dichiarata nel file config.php non presente nel plugin
	 */
	const CLASS_NOT_FOUND = 3;

	/**
	 * Il nome del plugin nel file config.php non è valido
	 */
	const INVALID_PLUGIN_NAME = 4;

	/**
	 * Il plugin non estende la classe BXD_Plugin_Abstract_Config
	 */
	const INVALID_EXTENDS_TYPE_CLASS = 5;

	/**
	 * Il plugin non implementa l'interfaccia BXD_Plugin_Interface_Config
	 */
	const INVALID_IMPLEMENTS_TYPE_CLASS = 6;

	/**
	 * Il nome della classe di configurazione non è corretto
	 */
	const CONFIG_FILES_INCORRECT_DECLARATION_CLASS_NAME = 7;

	/**
	 * Esiste già un plugin attivo con il nome specificato
	 */
	const ALREADY_EXISTS = 8;

	/**
	 * La classe che contiene i plugin non è scrivibile
	 */
	const PLUGIN_FOLDER_IS_NOT_WRITABLE = 9;

	/**
	 * Il nome del plugin non è definito
	 */
	const PLUGIN_NAME_IS_NOT_DEFINED = 10;

	/**
	 * La cartella dove dovranno essere copiate le classi non è specificata
	 */
	const FOLDER_PLUGIN_IS_NOT_SPECIFIED = 11;

	/**
	 * La cartella dove dovranno essere copiate le classi è già presente nel sistema
	 */
	const FOLDER_PLUGIN_ALREADY_EXISTS = 12;

	/**
	 * La cartella del plugin non esiste
	 */
	const APPLICATION_PLUGIN_INCORRECT_PLUGIN_FOLDER = 13;

	/**
	 * Il file di configurazione del plugin non esiste
	 */
	const APPLICATION_PLUGIN_CONFIG_FILE_NOT_FOUND = 14;

	/**
	 * Il file di configurazione del plugin non esiste
	 */
	const BXD_PLUGIN_CONFIGURATION_FILE_NOT_FOUND = 15;

	/**
	 * La cartella del plugin non esiste
	 */
	const BXD_PLUGIN_INCORRECT_PLUGIN_FOLDER = 16;

	/**
	 * Il file di configurazione del plugin non esiste
	 */
	const BXD_PLUGIN_CONFIG_FILE_NOT_FOUND = 17;

	/**
	 * La cartella che contiene i controller non è scrivibile
	 */
	const CONTROLLER_FOLDER_IS_NOT_WRITABLE = 18;

	/**
	 * Il controller non è presente all'interno del plugin
	 */
	const CONTROLLER_NOT_FOUND_INTO_PLUGIN = 19;

	/**
	 * Il controller è già presente nei controller dell'applicazione
	 */
	const CONTROLLER_ALREAD_EXISTS = 20;

	/**
	 * La cartella che contiene i controller non è scrivibile
	 */
	const ACTION_FOLDER_IS_NOT_WRITABLE = 21;

	/**
	 * Il controller non è presente all'interno del plugin
	 */
	const ACTION_NOT_FOUND_INTO_PLUGIN = 22;

	/**
	 * Il controller è già presente nei controller dell'applicazione
	 */
	const ACTION_ALREAD_EXISTS = 23;

	/**
	 * La webroot non è scrivibile
	 */
	const WEBROOT_FOLDER_IS_NOT_WRITABLE = 24;

	/**
	 * Il file media non è presente nel plugin
	 */
	const MEDIA_NOT_FOUND_INTO_PLUGIN = 25;

	/**
	 * Il file media è già presente nella webroot
	 */
	const MEDIA_ALREAD_EXISTS = 26;

	public function __construct($params, $code)
	{
		switch($code)
		{
			case self::PLUGIN_NOT_FOUND :
				$message = sprintf("'%s' plugin not found into bxd plugin", $params);
				break;

			case self::CONFIG_PHP_NOT_FOUND :
				$message = sprintf("'config.php' file not found into '%s' folder", $params);
				break;

			case self::CLASS_NOT_FOUND :
				$message = sprintf("'%s' class not found into '%s' plugin", $params[0], $params[1]);
				break;

			case self::INVALID_PLUGIN_NAME :
				$message = sprintf("Invalid plugin name into 'config.php'. The name must be '%s'", $params);
				break;

			case self::INVALID_EXTENDS_TYPE_CLASS :
				$message = sprintf("'%s' plugin not extends the class BXD_Plugin_Abstract_Config", $params);
				break;

			case self::INVALID_IMPLEMENTS_TYPE_CLASS :
				$message = sprintf("'%s' plugin not implements the class BXD_Plugin_Interface_Config", $params);
				break;

			case self::CONFIG_FILES_INCORRECT_DECLARATION_CLASS_NAME :
				$message = sprintf("Incorrect class name into '%s' file. The system is waiting for the name '%s'", $params[0], $params[1]);
				break;

			case self::ALREADY_EXISTS :
				$message = sprintf("'%s' plugin name is already in use", $params);
				break;

			case self::PLUGIN_FOLDER_IS_NOT_WRITABLE :
				$message = sprintf("'%s' is not writable. Set the permission on 0777", $params);
				break;

			case self::PLUGIN_NAME_IS_NOT_DEFINED :
				$message = sprintf("'%s' > Plugin name in not defined into annotation of the config class", $params);
				break;

			case self::FOLDER_PLUGIN_IS_NOT_SPECIFIED :
				$message = "Plugin folder is not specified into configuration file";
				break;

			case self::FOLDER_PLUGIN_ALREADY_EXISTS :
				$message = sprintf("'%s' folder already exists into plugin folder", $params);
				break;

			case self::APPLICATION_PLUGIN_INCORRECT_PLUGIN_FOLDER :
				$message = sprintf("The folder '%s', required by plugin '%s', was not found in the plugins folder of your application", $params[0], $params[1]);
				break;

			case self::APPLICATION_PLUGIN_CONFIG_FILE_NOT_FOUND :
				$message = sprintf("The configuration file for the plugin '%s' was not found in the plugins folder of your application", $params);
				break;

			case self::BXD_PLUGIN_CONFIGURATION_FILE_NOT_FOUND :
				$message = sprintf("The file 'bxd_plugin.conf' not found into '%' folder", $params);
				break;

			case self::BXD_PLUGIN_INCORRECT_PLUGIN_FOLDER :
				$message = sprintf("The folder '%s', required by plugin '%s', was not found in the plugins folder of bxd framework", $params[0], $params[1]);
				break;

			case self::BXD_PLUGIN_CONFIG_FILE_NOT_FOUND :
				$message = sprintf("The configuration file for the plugin '%s' was not found in the plugins folder of bxd framework", $params);
				break;

			case self::CONTROLLER_FOLDER_IS_NOT_WRITABLE :
				$message = sprintf("'%s' is not writable. Set the permission on 0777", $params);
				break;

			case self::CONTROLLER_NOT_FOUND_INTO_PLUGIN :
				$message = sprintf("'%s' controller not found into plugin '%s'", $params[0], $params[1]);
				break;

			case self::CONTROLLER_ALREAD_EXISTS :
				$message = sprintf("'%s' controller is already in use", $params);
				break;

			case self::ACTION_FOLDER_IS_NOT_WRITABLE :
				$message = sprintf("'%s' is not writable. Set the permission on 0777", $params);
				break;

			case self::ACTION_NOT_FOUND_INTO_PLUGIN :
				$message = sprintf("'%s' action not found into plugin '%s'", $params[0], $params[1]);
				break;

			case self::ACTION_ALREAD_EXISTS :
				$message = sprintf("'%s' action is already in use", $params);
				break;

			case self::WEBROOT_FOLDER_IS_NOT_WRITABLE :
				$message = sprintf("'%s' is not writable. Set the permission on 0777", $params);
				break;

			case self::MEDIA_NOT_FOUND_INTO_PLUGIN :
				$message = sprintf("'%s' not found into plugin '%s'", $params[0], $params[1]);
				break;

			case self::MEDIA_ALREAD_EXISTS :
				$message = sprintf("'%s' is already exist", $params);
				break;
		}

		parent::__construct($message, $code);
	}
}
?>